import Cookies from 'js-cookie'
import Vue from 'vue'
const vue = new Vue()

const TokenKey = 'Enterprise-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}
export function getVersionType() {
  return vue.$pt.getStorageSync('versionType')
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function clearStorageSync() {
  // 清除所有缓存
  return vue.$pt.clearStorageSync()
}

export function setEnterpriseId(enterpriseId) {
  vue.$pt.setStorageSync('enterpriseId', enterpriseId)
}
export function setSupplierId(supplierId) {
  vue.$pt.setStorageSync('supplierId', supplierId)
}
export function setWarehouseId(warehouseId) {
  vue.$pt.setStorageSync('warehouseId', warehouseId)
}
export function setMemberId(memberId) {
  vue.$pt.setStorageSync('memberId', memberId)
}
export function setEnterpriseLogoBanner(enterpriseLogoBanner) {
  vue.$pt.setStorageSync('enterpriseLogoBanner', enterpriseLogoBanner)
}
export function setEnterpriseLogoBannerMini(enterpriseLogoBannerMini) {
  vue.$pt.setStorageSync('enterpriseLogoBannerMini', enterpriseLogoBannerMini)
}
export function setEnterpriseInfo(enterpriseInfo) {
  vue.$pt.setStorageSync('enterpriseInfo', JSON.stringify(enterpriseInfo))
}
export function setUserCode(userCode) {
  vue.$pt.setStorageSync('userCode', userCode)
}
export function setUserId(userId) {
  vue.$pt.setStorageSync('userId', userId)
}
export function setUserName(userName) {
  vue.$pt.setStorageSync('userName', userName)
}
export function setPhone(phone) {
  vue.$pt.setStorageSync('phone', phone)
}
export function setVersionType(versionType) {
  vue.$pt.setStorageSync('versionType', versionType)
}
export function setEnterpriseConfig(enterpriseConfig) {
  vue.$pt.setStorageSync('enterpriseConfig', JSON.stringify(enterpriseConfig))
}
export function setSystemRoleType(systemRoleType) {
  vue.$pt.setStorageSync('systemRoleType', systemRoleType)
}
